package org.hk.kg.finance.student.action;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.hk.kg.db.DBServiceProxy;
import org.hk.kg.finance.FinanceConstants;
import org.hk.kg.finance.stuclz.service.IStuClzService;
import org.hk.kg.finance.stuclz.service.StuClzService;
import org.hk.kg.finance.student.service.IStudentService;
import org.hk.kg.finance.student.service.StudentService;
import org.hk.kg.finance.stutype.service.IStuTypeService;
import org.hk.kg.finance.stutype.service.StuTypeService;
import org.hk.kg.utils.Constants;
import org.hk.kg.web.BaseAction;

public class BaseStudentAction extends BaseAction {
	private IStuTypeService stuTypeServ = DBServiceProxy.getProxyClz(StuTypeService.class);
	private IStuClzService stuClzServ = DBServiceProxy.getProxyClz(StuClzService.class);
	protected IStudentService studentService = DBServiceProxy.getProxyClz(StudentService.class);
	
	public String getStuTypes()
	{
		List<Map> rlt = stuTypeServ.queryStuTypes();
		StringBuffer buffer = new StringBuffer();
		for(Map m : rlt)
		{
			buffer.append("<option value=\"").append(m.get("typeId")).append("\">")
				.append(m.get("typeName")).append("</option>\n");
		}
		return buffer.toString();
	}
	
	public String getStuClasses()
	{
		StringBuffer sbf=new StringBuffer();
		List<Map> rlt = stuClzServ.query();
		for(Map m : rlt)
		{
			sbf.append("<option value=\"").append(m.get("stuClzId")).append("\">")
			.append(m.get("stuClzName")).append("</option>\n");
		}
		return sbf.toString();
	}
	
	public String getStuSexes()
	{
		Map<String, String> sexes = Constants.CONFIG.getGroup(FinanceConstants.STU_SEX_CONSTANTS);
		StringBuffer buffer = new StringBuffer();
		for(Entry<String, String> entry : sexes.entrySet())
		{
			buffer.append("<option value=\"").append(entry.getKey()).append("\">")
			.append(entry.getValue()).append("</option>\n");
		}
		return buffer.toString();
	}
}
